package com.rd.p2p.app.score;

import java.io.IOException;

import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ModelDriven;
import com.qdlc.p2p.biz.service.ScoreService;
import com.qdlc.p2p.biz.web.action.BaseAction;
import com.qdlc.p2p.dal.dto.Score;
import com.qdlc.p2p.dal.dto.User;

public class AppScoreAction extends BaseAction<Score> implements ModelDriven<Score> {
	@Autowired
	private ScoreService scoreService;

	/**
	 * 当前账户的积分
	 */
	@Action("/app/member/score")
	public void getScore() throws IOException {
		User user = getSessionUser();
		if (user == null) {
			printWebResCodeAndMsgResult("-1","用户尚未登陆!");
			return;
		}
		Score score = scoreService.findByUserId(user.getUserId());
		if (score == null) {
			score = new Score();
		}
		// 临时处理方法,只需显示积分的信息即可
		score.setUser(null);
		printWebJson(getStringOfJpaObj(score));
	}
}
